library(RSuperMap)
library(sp)
library(gstat)

datasource = OpenDatasource("E:/d.udb", alias="data", engine = "udb")
pntdat = GetDatasets(datasource)[["data"]]
bounds = GetBounds(pntdat)
sp.data = Query2DF(pntdat)
xgrid <- seq(bounds[1,1], bounds[2,1], by = 0.001) 
ygrid <- seq(bounds[2,2], bounds[1,2], by = 0.001) 
grid.xy <- expand.grid(xgrid, ygrid)

colnames(grid.xy) <- c("x", "y")
coordinates(grid.xy) <- ~x+y
gridded(grid.xy) <- TRUE

idw.res <- idw(formula = log(StatisticsObjNum_1) ~ 1, locations = sp.data, newdata=grid.xy)
spplot(idw.res, zcol = "var1.pred", main = "IDW",  col.regions = terrain.colors(32))

Sp2Raster(idw.res, datasource, "raster", "SINGLE")

CloseDatasource(datasource)
